/*
	ScannerRule.h
	Define CScannerRule class

	@author Wolfhead
*/

#pragma once

#ifndef _CSCANNER_RULE_H_
#define _CSCANNER_RULE_H_

#include "Code.h"
#include "Token/Token.h"

MAKE_PTR(CScannerRule);


class CScannerRule
{
public:
	typedef CTerminateTokenPtr (*NumberScanFunc)(CCodePtr);
	typedef CTerminateTokenPtr (*WordScanFunc)(CCodePtr);
	typedef void (*SkipSpaceFunc)(CCodePtr);
	typedef CTerminateTokenPtr (*StringScanFunc)(CCodePtr);

public:
	static CScannerRulePtr create()
	{
		return CScannerRulePtr(new CScannerRule());
	}

public:
	CScannerRule(void);
	~CScannerRule(void);

private:
	
	CScannerRule(const CScannerRule&);
	CScannerRule& operator=(const CScannerRule&);

private:
	class IMPL;
	IMPL* pImplement;

public:
	
	int RegisterSpecialToken(const char* pToken, Token_Type Type);
	int RegisterSkipSpaceFunc(SkipSpaceFunc func);
	int RegisterNumberScanFunc(NumberScanFunc func);
	int RegisterWordScanFunc(WordScanFunc func);
	int RegisterKeyWord(const char* pKeyWord, Token_Type Type);
	int RegisterStringScanFunc(StringScanFunc func);

	void SkipSpace(CCodePtr pCode);
	CTerminateTokenPtr ScanSpecialToken(CCodePtr pCode);
	CTerminateTokenPtr ScanNumber(CCodePtr pCode);
	CTerminateTokenPtr ScanWord(CCodePtr pCode);
	CTerminateTokenPtr ScanString(CCodePtr pCode);

};

#endif //#ifndef _CSCANNER_RULE_H_
